using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Elo.Exemplo.EFCodeFirst.Domain.Entities;

namespace Elo.Exemplo.EFCodeFirst.Domain.Mapping
{
	public class Order_Details_ExtendedMap : EntityTypeConfiguration<Order_Details_Extended>
	{
		public Order_Details_ExtendedMap()
		{
			// Primary Key
			this.HasKey(t => new { t.OrderID, t.ProductID, t.ProductName, t.UnitPrice, t.Quantity, t.Discount });

			// Properties
			this.Property(t => t.OrderID)
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
				
			this.Property(t => t.ProductID)
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
				
			this.Property(t => t.ProductName)
				.IsRequired()
				.HasMaxLength(40);
				
			this.Property(t => t.UnitPrice)
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
				
			// Table & Column Mappings
			this.ToTable("Order Details Extended");
			this.Property(t => t.OrderID).HasColumnName("OrderID");
			this.Property(t => t.ProductID).HasColumnName("ProductID");
			this.Property(t => t.ProductName).HasColumnName("ProductName");
			this.Property(t => t.UnitPrice).HasColumnName("UnitPrice");
			this.Property(t => t.Quantity).HasColumnName("Quantity");
			this.Property(t => t.Discount).HasColumnName("Discount");
			this.Property(t => t.ExtendedPrice).HasColumnName("ExtendedPrice");
		}
	}
}

